//
//  shaidanListVC.m
//  BeautyPicture
//
//  Created by 沈振邦 on 16/1/8.
//  Copyright © 2016年 szb. All rights reserved.
//

#import "shaidanListVC.h"
#import "BPhttpTool.h"
#import "AccountTool.h"
#import "indentModel.h"
#import "MJExtension.h"
#import "shaidanViewController.h"

@interface shaidanListVC ()

@property (nonatomic,weak)UILabel *noaddressLabel;

@end

@implementation shaidanListVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.headView.hidden = YES;
    self.dataArray = [NSMutableArray array];
    self.orderTableView.y = BPScreenNavY;
    [self setUpNoListLable];
    // Do any additional setup after loading the view.
}

- (void)setUpNoListLable{
    UILabel *noAddressLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, BPScreenNavY, BPScreenW, 30.0f)];
    noAddressLabel.backgroundColor = BPGlobaBGColor;
    noAddressLabel.text = @"您还没有可以晒的订单";
    noAddressLabel.textAlignment = NSTextAlignmentCenter;
    noAddressLabel.textColor = [UIColor whiteColor];
    noAddressLabel.font = [UIFont systemFontOfSize:15.0f];
    noAddressLabel.hidden = YES;
    [self.view addSubview:noAddressLabel];
    self.noaddressLabel = noAddressLabel;
}

- (void)isHaveData
{
    if (self.dataArray.count == 0) {
        self.noaddressLabel.hidden = NO;
    }else{
        self.noaddressLabel.hidden = YES;
    }
}

- (void)getOrderData
{
    [BPhttpTool get:[NSString stringWithFormat:@"%@order/orderlist/uid/%@",BPhttp,[AccountTool account].uid] params:nil success:^(id responseObj) {
        NSArray *arry = [indentModel objectArrayWithKeyValuesArray:responseObj];
        for (indentModel *model in arry) {
            int number = [model.status intValue];
             if (number == 500 && [model.isshare intValue] == 0){
                 [self.dataArray addObject:model];
            }
        }
        [self isHaveData];
        [self.orderTableView reloadData];
    } failure:^(NSError *error) {
        BPLog(@"获取失败");
    }];
}

- (void)quickShaidan:(childBaseTableViewCell *)childBaseCell
{
    NSIndexPath *indexPath = [self.orderTableView indexPathForCell:childBaseCell];
    indentModel *model = self.dataArray[indexPath.row];
    shaidanViewController *shaidan = [[shaidanViewController alloc] init];
    shaidan.orderID = model.iD;
    shaidan.block = ^(){
        model.isshare = @"1";
        [self.dataArray removeObject:model];
        [self.orderTableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
        _block();
    };
    [self.navigationController pushViewController:shaidan animated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
